#include <stdio.h>

int n, k;
int cigs;
int add;
int butts;

int main() {
	while (scanf("%d %d", &n, &k)!=EOF) {
		butts=n;
		cigs=n;

		while (butts/k) {
			add=butts/k;
			cigs+=add;
			butts=butts%k+add;
		}

		printf("%d\n", cigs);
	}

	return 0;
}
